package com.qf.handerException;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author Ypl
 * @version V1.0
 * @Project September-mavens
 * @Package com.qf.handerException
 * @Description:
 * @Date 2022/10/8 16:03
 */
@SuppressWarnings("all")
@ControllerAdvice
public class MyExceprion03 {

    /**
     * 处理运行时异常
     * @param e
     * @return
     */

    @ExceptionHandler({
            RuntimeException.class
    })

    @ResponseBody
    public Object handlerRuntimeException(RuntimeException e) {
        e.printStackTrace();
        return "我在运行的时候error了";
    }

    /**
     * 处理其他异常
     * @param e
     * @return
     */

    @ExceptionHandler({
            Exception.class
    })
    @ResponseBody
    public Object handlerOtherException(Exception e) {
        e.printStackTrace();
        return "我在其他的时候error了";
    }
}
